home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / C / XMSSTUFF.ZIP / README.TXT next >
Encoding:
Text File  |  1996-12-07  |  5.6 KB  |  177 lines

  1.                         XMS Memory Routines in C
  2.                     (c) Copyright Jeff Leigh - 1997
  3.                                 
  4.                               By Jeff Leigh
  5.  
  6. Here is my XMS memory access routines.  Anyone familiar with XMS should get
  7. them to work without any problems (Hmm, that is what they told me when I 
  8. started my EMS routines that never worked. Hmm...) 
  9.  
  10. I distribute these routines as freeware - you may use them in any project 
  11. personal or commercial as long as you give me some sort of credit, like 
  12. "XMS routines programmed by Jeff Leigh."  Or you could just call your game or 
  13. program "Jeff Leigh's Program" (is that going to far?)  Of course, if you feel 
  14. inclined to give me a few bucks, perhaps enough to buy lunch or something, it 
  15. would be really appreciated (especially if you use these routines in a 
  16. commercial product.)
  17.  
  18. DISCLAIMER: Jeff Leigh is not in any way responsible for any damage to you, 
  19. your house, any of your property, your dog, your friends, your relatives, 
  20. your hair, the guy next door, the mailman, your car, your mental status, or 
  21. even your computer.  As a matter of fact, if difficulties are incurred do to 
  22. the use of these routines, Jeff Leigh doesn't even know that these routines 
  23. exist. 
  24.  
  25. Specifications:
  26.  
  27. The routines where written in Microsoft QuickC v2.5, using the MEDIUM memory 
  28. model, and I don't know if they work in other memory modes.  
  29.  
  30. The important files are
  31.  
  32. XMSSTUFF.C   - the library of routines.
  33. XMSSTUFF.OBJ - the OBJ file in case you want to link to it.
  34. XMS.C        - a cute little test/demo program    
  35.  
  36. As way of documentation, I have included the following information.
  37.  
  38. THE XMS_* functions
  39.  
  40. int XMS_detect( void )
  41.  
  42. This routine detects if XMS is present, returning 1 if it is and 0 if not.
  43. YOU MUST RUN THIS PROCEDURE BEFORE ANY OTHERS!!!
  44.  
  45. void XMS_ini( void )
  46.  
  47. This performs vital operations, and should be called after you call
  48. XMS_ini and before you call any other routines.
  49.  
  50. unsigned int XMS_largestavail( void )
  51.  
  52. This returns the largest block of consecutive memory.
  53.  
  54. unsigned int XMS_memavail( void )
  55.  
  56. This returns the amount of free XMS memory.
  57.  
  58. unsigned int XMS_allocate_block( unsigned int amount )
  59.  
  60. This allocates a block of memory the size of (AMOUNT)kb.  Notice that this
  61. is in Kilobytes.  That means sending 64 as your amount would allocate 64,000
  62. bytes.  The function returns a simple integer handle.  You should keep track
  63. of this number, because it is in effect the variable name of that region
  64. of memory.
  65.  
  66. int XMS_free_block( unsigned int handle )
  67.  
  68. This routine frees a block of memory previously allocated with 
  69. XMS_allocate_block.  It returns a simple success code (0 or 1).
  70.  
  71. char XMS_handles_free( unsigned int handle )
  72.  
  73. Returns the amount of handles free to the system (defined in config.sys as
  74. HANDLES = xx) you need at least one to do anything.  The less of these that
  75. you use, the better.
  76.  
  77. int XMS_move_block( struct ExtMemMoveStruct _far *structin )
  78.  
  79. This is the hard way to move memory around.  You will have to decipher the 
  80. structure included in the header file.  Use this if you want, or use my 
  81. personal extensions ( discussed later, see XMSE_* functions)
  82.  
  83. ALL LENGTHS MUST BE EVEN!! (no odd numbers like 20123, round up to 20124)
  84. It is faster if you can word-align the length.
  85. Even faster if you can Dword-align the length.
  86.  
  87. char _far *XMS_lock_block( unsigned int handle )
  88.  
  89. This locks a block of memory if you want to do that.  None of my programs
  90. do so, and it is not required to move memory using XMS_move_block or my XMSE_*
  91. routines.  You will probably never use this.  Locked data should be unlocked
  92. as soon as possible.
  93.  
  94. int XMS_unlock_block( unsigned int handle )
  95.  
  96. Same thing here.  Don't use unless you know what you are doing...
  97.  
  98. int XMS_enable_A20( void )
  99.  
  100. Enables the processor's A20 line.
  101. Again, another routine not to be used unless you are familiar with XMS memory.
  102. Of course, if you are familiar, then you will probably have your own 
  103. routines...
  104.  
  105. int XMS_disable_A20( void )
  106.  
  107. Disables the processor's A20 line.
  108.  
  109. The XMSE_* functions
  110.  
  111. These functions are extra functions to make moving data easier.
  112.  
  113. int XMSE_xms_to_con( unsigned int handle, char _far *data, unsigned int length )
  114.  
  115. Give this procedure the handle of the XMS data, where in memory you want the 
  116. data sent, and the length of the data.
  117.  
  118. ALL LENGTHS MUST BE EVEN!! (no odd numbers like 20123, round up to 20124)
  119. It is faster if you can word-align the length.
  120. Even faster if you can Dword-align the length.
  121.  
  122. int XMSE_con_to_xms( unsigned int handle, char _far *data, unsigned int length )
  123.  
  124. Copies data you have in conventional memory to an handle of XMS memory.
  125. Give it the location of the data, and a XMS handle, and the length of the 
  126. data.
  127.  
  128. One more time, just so you don't try it...
  129. ALL LENGTHS MUST BE EVEN!!! (No odd numbers like 20123, round up to 20124)
  130. It is faster if you can word-align the length.
  131. Even faster if you can Dword-align the length.
  132.  
  133. Well, I hope you like my routines.  
  134. If you are unsure about how to use something, check out XMS.C to see how I 
  135. used them.  (it uses all the routines.  It copies data to XMS, clears the 
  136. data in conventional, transfers it back, then checks to see if it matches the 
  137. original.)
  138. If you do use them, drop me a line on CompuServe at Jeff Leigh - 70144,3460.
  139.  
  140. Be sure to ask me how my game is going, so that I don't give up on it and 
  141. quit!!!
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153. Okay. I'm done.
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174. What do you want?  
  175. Big deal if I couldn't get EMS to work! No one uses anymore anyway!
  176. Besides, I am a REAL programmer.  I can do anything...
  177.